/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import java.util.Random;
import model.Ticket;

/**
 *
 * @author Matthy & Jelle
 */
public class TicketService extends AbstractService{

  @Override
  public boolean validate(Object o) {
    Ticket t = (Ticket) o;
    Boolean ret = true;
    if (t.getVerkoop() == null) {
      return false;
    }
    else {
      // prevent infinite loops.
      VerkoopService vs = new VerkoopService();
      if(!vs.validate(t.getVerkoop().clone())) {
        return false;
      }

    }
    if (t.getVoorstelling() == null) {
      return false;
    }
    return true;
  }

  public Integer generateBarcode() {
    Random r = new Random();
    return Math.abs(r.nextInt());
  }

}
